/**
 * 自动引入模板，在原有 sw-precache 插件默认模板基础上做的二次开发
 *
 * 因为是自定导入的模板，项目一旦生成，不支持随 sw-precache 的版本自动升级。
 * 可以到 Lavas 官网下载 basic 模板内获取最新模板进行替换
 *
 */

/* eslint-disable */

'use strict';

var precacheConfig = [["/sedog/2020/07/10/测试/index.html","d84bc12d8b2f640dcdc232fba1b51887"],["/sedog/2020/07/10/测试1/index.html","f9bf628596fb1b2d72f2ebf934beb396"],["/sedog/2020/07/10/测试2/index.html","1a4896aebbcd40cbc2e6a761b361151e"],["/sedog/2020/07/10/测试3/index.html","d99fbb6bd1ab754cb0ba88320ff2de8b"],["/sedog/2020/07/10/测试4/index.html","424aab9bd065c354cebc1cfe669c85fb"],["/sedog/2020/07/14/测试10/index.html","021e5dfb0f0dce5ccd9b9df21e117175"],["/sedog/2020/07/14/测试11/index.html","79f85f642952711347476a3825ac4ca3"],["/sedog/2020/07/14/测试12/index.html","8d1dc39ceb9e3ad07f739b558f88af2f"],["/sedog/2020/07/14/测试13/index.html","33ea016051d518c51d0384f7e9b487e8"],["/sedog/2020/07/14/测试14/index.html","2c347954598cfea5a5fcba0065ab52a6"],["/sedog/2020/07/14/测试15/index.html","08701dbd12e2202069ad67dd7331f6f6"],["/sedog/2020/07/14/测试16/index.html","83d261b59430780841161fd7b84dda23"],["/sedog/2020/07/14/测试5/index.html","c8760d56e8f52cb531c3855222acf6af"],["/sedog/2020/07/14/测试6/index.html","2f28a2c7f9e0e06023a9f39145242eeb"],["/sedog/2020/07/14/测试7/index.html","7a44b0f473d5a57a6bf169afe2f50cac"],["/sedog/2020/07/14/测试8/index.html","5e552c6a200d184a9808f4d919d443fe"],["/sedog/2020/07/14/测试9/index.html","0f8a931838a62af001a77daf541477aa"],["/sedog/2020/07/26/测试17/index.html","41c9fb3efaebb071bb2f6c66e3a6061c"],["/sedog/2020/07/26/测试18/index.html","fe8a191d371d3fc257fa53a16218c20b"],["/sedog/2020/08/16/测试19/index.html","4a59e7cdef7c5a3131cc8836d099d781"],["/sedog/2020/08/16/测试20/index.html","b25c6892caa628bb566d21e12553f0cb"],["/sedog/about/index.html","524c8be9462300037cd1b6581f3b22c4"],["/sedog/archives/2020/07/index.html","e4d324b586aaf522f9b5599f65fa0926"],["/sedog/archives/2020/07/page/2/index.html","505afd9b8631cd402570e52393c26e30"],["/sedog/archives/2020/08/index.html","41b84f54cf2bae68ab0d411896d13c34"],["/sedog/archives/2020/index.html","bc6d973dcfc270ca484477158cb1a358"],["/sedog/archives/2020/page/2/index.html","705a8ff40f816d72dce95f27a3718c84"],["/sedog/archives/2020/page/3/index.html","2373ef311efd623a29cff864a87f28ee"],["/sedog/archives/index.html","5690c2f41cf4c09e3a19139cc9869412"],["/sedog/archives/page/2/index.html","9f041a9b3f8debf44548bfa42cba0c9c"],["/sedog/archives/page/3/index.html","781870a03052ead33e48fa4a88259c2d"],["/sedog/assets/css/APlayer.min.css","fbe994054426fadb2dff69d824c5c67a"],["/sedog/assets/js/APlayer.min.js","8f1017e7a73737e631ff95fa51e4e7d7"],["/sedog/assets/js/Meting.min.js","bfac0368480fd344282ec018d28f173d"],["/sedog/categories/index.html","6df639f0ea48457278ea68f1d61aae1f"],["/sedog/categories/uncategorized/index.html","7bec1d6eed181250ad6ef572fa410ff9"],["/sedog/categories/uncategorized/page/2/index.html","931fd2dfc3d1a650a8d3f1138f1e96eb"],["/sedog/categories/uncategorized/page/3/index.html","5a53b1870e3554a9d616c9b57f49f871"],["/sedog/css/blog-encrypt.css","ee21c7086a59d52b97a9e7b6240a9414"],["/sedog/css/main.css","6e900a693490debf18e8c56f8c3015ba"],["/sedog/dist/APlayer.min.css","a84d242b1fb3b4d2a55ce43824638c95"],["/sedog/dist/APlayer.min.js","8f1017e7a73737e631ff95fa51e4e7d7"],["/sedog/dist/music.js","a87485aa75e5177ef2b06bf948e31075"],["/sedog/figlet/fetch.min.js","350d73710c8e7facd458e74b17b96c27"],["/sedog/figlet/figlet.js","0dcd07654130a5de80d46793553ba41b"],["/sedog/flash/flash/index.html","d5dbc89f351aa14ce157f7afc4cda760"],["/sedog/flash/index.html","1da9cce83d8c5c674b37982682064cbd"],["/sedog/help/index.html","71668de47f217d91a107a6b8880beebc"],["/sedog/images/algolia_logo.svg","fd40b88ac5370a5353a50b8175c1f367"],["/sedog/images/alipay.jpg","d9452503de1e4195e67028f073c5addb"],["/sedog/images/apple-touch-icon-next.png","fce961f0bd3cd769bf9c605ae6749bc0"],["/sedog/images/avatar.gif","c6e949a6226bcf46b24676d7ff90de88"],["/sedog/images/cc-by-nc-nd.svg","1c681acc4a150e7236254c464bb5a797"],["/sedog/images/cc-by-nc-sa.svg","12b4b29e8453be5b7828b524d3feabce"],["/sedog/images/cc-by-nc.svg","dd9cfe99ed839a4a548114f988d653f4"],["/sedog/images/cc-by-nd.svg","2d80546af20128215dc1e23ef42d06c2"],["/sedog/images/cc-by-sa.svg","c696b3db81cbbfba32f66c1dc88b909a"],["/sedog/images/cc-by.svg","6c4f8422b3725cb9f26b6c00e95fc88b"],["/sedog/images/cc-zero.svg","79deee77a07fcb79ff680ac0125eacb9"],["/sedog/images/failure.png","38ff0bc871eae50300877ef019eac4b5"],["/sedog/images/favicon-16x16-next .png","cb9f23934fe03bc9d284da68e659d847"],["/sedog/images/favicon-32x32-next.png","896f4eb152b3798ed17bfc57d1d3e505"],["/sedog/images/head.jpg","c6e949a6226bcf46b24676d7ff90de88"],["/sedog/images/hot.png","a90be0de558143aabf0acc9cfa0a8688"],["/sedog/images/icon-slides.png","5efa36b1d0ef0b5fbb33813582d3b405"],["/sedog/images/linkcard.png","f5f5a1ff80b9f2403d76d0092128df19"],["/sedog/images/linkcard_bak.png","e1f9f6973a3d2c38b0b2b7317bd7b317"],["/sedog/images/loading.gif","c2196de8ba412c60c22ab491af7b1409"],["/sedog/images/logo.svg","ddad9027e42111ccd5b466bc18188970"],["/sedog/images/placeholder.gif","c2196de8ba412c60c22ab491af7b1409"],["/sedog/images/qq.png","3120192dd3ece9c019de0103f39737a0"],["/sedog/images/quote-l.svg","1238a4baccd02c6025ec85b58f4282d4"],["/sedog/images/quote-r.svg","85787c6fa27965c81f7be70252b43bed"],["/sedog/images/read.png","4462c81055423c8d2db56a77b51c5cb8"],["/sedog/images/rocket.png","bccdd1a3718ff55c4bac6c7c11e436ee"],["/sedog/images/scroll.png","b0605bbb765779aa0d422643acfdc3bf"],["/sedog/images/searchicon.png","3d6b5c9d6d6c26a2b76a14b8fdf3438a"],["/sedog/images/subscribe.png","641c2d396a563ddafa6fed34a9984a03"],["/sedog/images/subscribe1.png","d4accaba47d6e791ce0cd6365735992f"],["/sedog/images/subscribe~1.png","e147141e7f29ff2bb46356cc8ca7c831"],["/sedog/images/time.png","7412c44c18963032d2d121ce0cb8809f"],["/sedog/images/wechat.svg","2ef3f3696267249c4372a5e3f9db36f2"],["/sedog/images/wechatpay.jpg","d9dbc02b5f7c379adac84eeb7f6f51b6"],["/sedog/images/xiaohutong.png","14589dbb580ac44e4c04e4e94f22ab0f"],["/sedog/index.html","ba9bc0fb8e93b72d86b437d307149ec8"],["/sedog/js/cursor/explosion.min.js","f8599b24e09ee8be2d30560755e38236"],["/sedog/js/cursor/fireworks.js","2c8509065e42a7bafeb4c599a6a6eaa9"],["/sedog/js/cursor/love.min.js","7bcfdb57debd43483174cf9e15ab37cc"],["/sedog/js/cursor/text.js","fbe111a3ab258f224f8c4b41c9b3e886"],["/sedog/js/src/Valine.min.js","6f1a471af66a428b60016a6e22e2784e"],["/sedog/js/src/activate-power-mode.min.js","b1e237aef80ed7a74f443be0d5dbb6e0"],["/sedog/js/src/affix.js","683c19859764baf0d17538897ea1eba2"],["/sedog/js/src/algolia-search.js","f5fa392318805997089ceb3a925979ba"],["/sedog/js/src/bootstrap.js","2a1083772854ae2663748e0a25c17285"],["/sedog/js/src/bubble.js","8fdcf8ca4941000b226b2e7535bf1af8"],["/sedog/js/src/clipboard-use.js","6245c44a33b72d0b5d04562b6808a309"],["/sedog/js/src/clipboard.min.js","f06c52bfddb458ad87349acf9fac06c5"],["/sedog/js/src/crash_cheat.js","a9f0920c901ee43e163479111c874163"],["/sedog/js/src/exturl.js","2b444179b3145e5007b4d371dac07cd3"],["/sedog/js/src/hook-duoshuo.js","45997b0c06abff3cd88efd901f614065"],["/sedog/js/src/js.cookie.js","6e9eb1f53afb135aedaf90739c867738"],["/sedog/js/src/linkcard.js","da6cb85a2c1d36027ca414459c8dd58f"],["/sedog/js/src/motion.js","0f6add86607c451269d0b3d286c84d8b"],["/sedog/js/src/post-details.js","b8e8e27c27c697567879c52888ffc24c"],["/sedog/js/src/schemes/pisces.js","827b5ad25e1142277c1e7dfe0cacebe5"],["/sedog/js/src/scroll-cookie.js","890406ae3539e4721ef5f314542e5e46"],["/sedog/js/src/scrollspy.js","fafdd7ab6af233b701506c733910b7f5"],["/sedog/js/src/utils.js","ee7e149030931501fa19b0ab74b46b34"],["/sedog/js/tagcanvas.js","222f58419252597da4e4b17828824a8f"],["/sedog/js/tagcloud.js","4d5b86e9e3c1180eeb33394c7a0937f0"],["/sedog/lib/Han/dist/font/han-space.woff","b09f2dd7d3ad8ad07f3b8495133909d9"],["/sedog/lib/Han/dist/font/han.woff","e841c6b547bc06a06f60f4de52bf906e"],["/sedog/lib/Han/dist/han.css","f8e397a8ab9f43f5d1998ba416e14aa6"],["/sedog/lib/Han/dist/han.js","575b6c1667c01798730fbd972e959c9c"],["/sedog/lib/Han/dist/han.min.css","1edb85c61b44560272a1599d75be0445"],["/sedog/lib/Han/dist/han.min.js","96482c9c2b3c5ea9bf5a40db162c7f34"],["/sedog/lib/algolia-instant-search/instantsearch.min.css","029a13b44e6807955106ff3c075a02f9"],["/sedog/lib/algolia-instant-search/instantsearch.min.js","0db46eba0c8133693ee839507b1612f2"],["/sedog/lib/blog-encrypt.js","f1c932790ec55934e04634fd752a3d8e"],["/sedog/lib/canvas-nest/canvas-nest.min.js","36e103d2a05bc706bac40f9ab8881eb7"],["/sedog/lib/canvas-ribbon/canvas-ribbon.js","16dc214240913551986593808c2efcfc"],["/sedog/lib/fancybox/source/blank.gif","325472601571f31e1bf00674c368d335"],["/sedog/lib/fancybox/source/fancybox_loading.gif","328cc0f6c78211485058d460e80f4fa8"],["/sedog/lib/fancybox/source/fancybox_loading@2x.gif","f92938639fa894a0e8ded1c3368abe98"],["/sedog/lib/fancybox/source/fancybox_overlay.png","77aeaa52715b898b73c74d68c630330e"],["/sedog/lib/fancybox/source/fancybox_sprite.png","783d4031fe50c3d83c960911e1fbc705"],["/sedog/lib/fancybox/source/fancybox_sprite@2x.png","ed9970ce22242421e66ff150aa97fe5f"],["/sedog/lib/fancybox/source/helpers/fancybox_buttons.png","b448080f8615e664b7788c7003803b59"],["/sedog/lib/fancybox/source/helpers/jquery.fancybox-buttons.css","2c0d9f3da1fc80904070b42e9419c94b"],["/sedog/lib/fancybox/source/helpers/jquery.fancybox-buttons.js","f53c246661fb995a3f12e67fa38e0fa0"],["/sedog/lib/fancybox/source/helpers/jquery.fancybox-media.js","c017067f48d97ec4a077ccdf056e6a2e"],["/sedog/lib/fancybox/source/helpers/jquery.fancybox-thumbs.css","52ddd84a9f42c1d4cd86d518a7f7e8bc"],["/sedog/lib/fancybox/source/helpers/jquery.fancybox-thumbs.js","cf1fc1df534eede4cb460c5cbd71aba6"],["/sedog/lib/fancybox/source/jquery.fancybox.css","33be4f7457613ddb50c9666c29be9476"],["/sedog/lib/fancybox/source/jquery.fancybox.js","921e9cb04ad6e2559869ec845c5be39b"],["/sedog/lib/fancybox/source/jquery.fancybox.pack.js","cc9e759f24ba773aeef8a131889d3728"],["/sedog/lib/fastclick/README.html","058880c0cf45ff313ea33ff1ce3762f8"],["/sedog/lib/fastclick/lib/fastclick.js","6e9d3b0da74f2a4a7042b494cdaa7c2e"],["/sedog/lib/fastclick/lib/fastclick.min.js","a0fc6c24d1f3ff9ac281887c92b24acd"],["/sedog/lib/font-awesome/css/font-awesome.css","76c27916461b5fbe7779d5b5785a7ecf"],["/sedog/lib/font-awesome/css/font-awesome.min.css","514518c4802348df7ca38304ab262b71"],["/sedog/lib/font-awesome/fonts/fontawesome-webfont.eot","674f50d287a8c48dc19ba404d20fe713"],["/sedog/lib/font-awesome/fonts/fontawesome-webfont.svg","912ec66d7572ff821749319396470bde"],["/sedog/lib/font-awesome/fonts/fontawesome-webfont.ttf","b06871f281fee6b241d60582ae9369b9"],["/sedog/lib/font-awesome/fonts/fontawesome-webfont.woff","fee66e712a8a08eef5805a46892932ad"],["/sedog/lib/jquery/index.js","32015dd42e9582a80a84736f5d9a44d7"],["/sedog/lib/jquery_lazyload/CONTRIBUTING.html","7b6d4d92d19a140aa42343a43f825b7a"],["/sedog/lib/jquery_lazyload/README.html","ebb0141fd395bdd81c3071d5c8799a33"],["/sedog/lib/jquery_lazyload/jquery.lazyload.js","8b427f9e86864ee3aaf1ae33e6e14263"],["/sedog/lib/jquery_lazyload/jquery.scrollstop.js","f163fd8f02361928853668a96f8a1249"],["/sedog/lib/needsharebutton/font-embedded.css","dd8861d10d1ed6b5e0c0011adfb39be9"],["/sedog/lib/needsharebutton/needsharebutton.css","980ac3b416360e5cd83131ac26da04ee"],["/sedog/lib/needsharebutton/needsharebutton.js","6c6f855f7d50f4bc3c804f52b03bbfbb"],["/sedog/lib/pace/pace-theme-barber-shop.min.css","5f956ec86e131981d5d31072a9dbd7b8"],["/sedog/lib/pace/pace-theme-big-counter.min.css","355670270f10982dac3251ba0c1db98b"],["/sedog/lib/pace/pace-theme-bounce.min.css","b95324e30c9b6c38df99ab5f115345cb"],["/sedog/lib/pace/pace-theme-center-atom.min.css","c6a4602ac13f9e081ae9f9ed1523617a"],["/sedog/lib/pace/pace-theme-center-circle.min.css","edc1f50b2603cba1ee861af1fbc73381"],["/sedog/lib/pace/pace-theme-center-radar.min.css","3e0d485aca3a01b5d9518c9769165ce4"],["/sedog/lib/pace/pace-theme-center-simple.min.css","1eea13ae155b3a8905f16238c9c00f7d"],["/sedog/lib/pace/pace-theme-corner-indicator.min.css","5d26ff9043e0822ec669a559db52e58c"],["/sedog/lib/pace/pace-theme-fill-left.min.css","b62157525079b1ccca8c13d4826566fe"],["/sedog/lib/pace/pace-theme-flash.min.css","58ee59d6b79024feedc6349e5082437e"],["/sedog/lib/pace/pace-theme-loading-bar.min.css","d95f0e502f303adae04448a688b5e88c"],["/sedog/lib/pace/pace-theme-mac-osx.min.css","4744d42ac62ce992641b292c28351742"],["/sedog/lib/pace/pace-theme-minimal.min.css","6049c157d34a29a7d4cfab72fa2f73be"],["/sedog/lib/pace/pace.min.js","24d2d5e3e331c4efa3cda1e1851b31a7"],["/sedog/lib/three/canvas_lines.min.js","1324174ae6190fbf63b7bf0ad0a8a5bd"],["/sedog/lib/three/canvas_sphere.min.js","5c6bc45b137448b5b9df152ccfb2659c"],["/sedog/lib/three/three-waves.min.js","41059bd5e5c7aa520b1b411919e5121f"],["/sedog/lib/three/three.min.js","3298078bce82bdb1afadf5b1a280915e"],["/sedog/lib/ua-parser-js/dist/ua-parser.min.js","a6e833266c4b41fabb9ba94a145322d8"],["/sedog/lib/ua-parser-js/dist/ua-parser.pack.js","6b627e4d61a7135952824bb9c1a4a134"],["/sedog/lib/velocity/velocity.js","0361fa6dcf4cf4d19c593cdab0937dd0"],["/sedog/lib/velocity/velocity.min.js","c1b8d079c7049879838d78e0b389965e"],["/sedog/lib/velocity/velocity.ui.js","f55d22cc592c9f8d4ffd3b41a6b90081"],["/sedog/lib/velocity/velocity.ui.min.js","444faf512fb24d50a5dec747cbbe39bd"],["/sedog/life/index.html","66681db43a4fb343e56f3bc4918c788c"],["/sedog/live2d-widget/README.html","65e85b3468e70709b59bd1ee06a67f6b"],["/sedog/live2d-widget/assets/screenshot-1.png","30b70e6cd9be9812adcb347536f0da85"],["/sedog/live2d-widget/assets/screenshot-2.png","cca95d7c3ce89495691acc300f63aef0"],["/sedog/live2d-widget/assets/screenshot-3.png","637681525dd86db9d1ed20e397498c30"],["/sedog/live2d-widget/autoload.js","fdff49a1ea5efd0d3bbd7ac8748b51f2"],["/sedog/live2d-widget/demo/demo1.html","79231045b6219efd3c5d78be6c7573b6"],["/sedog/live2d-widget/demo/demo2.html","a1237e559dcedd07fcc35798361068be"],["/sedog/live2d-widget/live2d.min.js","c1c28f553095fdddb4d2c13a11bd4cb9"],["/sedog/live2d-widget/waifu-tips.js","5d4707e2962f19113405c1f4d577bb58"],["/sedog/live2d-widget/waifu.css","20be8ab0cc011cab7565faeaf51a8081"],["/sedog/love/index.html","ad1c32f9d651903323b1b926c14ebb05"],["/sedog/page/2/index.html","687d1cd07a4391c66bd95b0c7cce1941"],["/sedog/page/3/index.html","a2ac41323a302b6cc788127adfefdda9"],["/sedog/sharejs/css/share.min.css","5302d280328f45bd351132938cfeb4c3"],["/sedog/sharejs/fonts/iconfont.eot","e83ffaa95463f987abe5db5bbbe303cc"],["/sedog/sharejs/fonts/iconfont.svg","eb5d36236b96681900e300ab19c620b6"],["/sedog/sharejs/fonts/iconfont.ttf","9ac2cc5ae8616eb50c033525dc14a5eb"],["/sedog/sharejs/fonts/iconfont.woff","bf0fc2ec6e2a614635e0ab6e81d059ef"],["/sedog/sharejs/js/jquery.share.min.js","1c3bf7d587a82e2611c01a5b284aa756"],["/sedog/sharejs/js/social-share.min.js","a11590a40662aa0470da0a9cf725e0be"],["/sedog/sw-register.js","7498104cd8d6cac5ca35549cbe06b76e"],["/sedog/tags/hexo博客/index.html","0228b840aeaa7bc5a2f4d7b8aa50c3fb"],["/sedog/tags/hexo博客/page/2/index.html","05a39f943edc30439c642aa1345ccc9d"],["/sedog/tags/hexo博客/page/3/index.html","22961ce7facf83bd085f2dbb55b81e8d"],["/sedog/tags/index.html","896383898a53961569bac80b956322b9"]];
var cacheName = 'sw-precache-v3--' + (self.registration ? self.registration.scope : '');
var firstRegister = 1; // 默认1是首次安装SW， 0是SW更新


var ignoreUrlParametersMatching = [/^utm_/];


var addDirectoryIndex = function (originalUrl, index) {
    var url = new URL(originalUrl);
    if (url.pathname.slice(-1) === '/') {
        url.pathname += index;
    }
    return url.toString();
};

var cleanResponse = function (originalResponse) {
    // 如果没有重定向响应，不需干啥
    if (!originalResponse.redirected) {
        return Promise.resolve(originalResponse);
    }

    // Firefox 50 及以下不知处 Response.body 流, 所以我们需要读取整个body以blob形式返回。
    var bodyPromise = 'body' in originalResponse ?
        Promise.resolve(originalResponse.body) :
        originalResponse.blob();

    return bodyPromise.then(function (body) {
        // new Response() 可同时支持 stream or Blob.
        return new Response(body, {
            headers: originalResponse.headers,
            status: originalResponse.status,
            statusText: originalResponse.statusText
        });
    });
};

var createCacheKey = function (originalUrl, paramName, paramValue,
    dontCacheBustUrlsMatching) {

    // 创建一个新的URL对象，避免影响原始URL
    var url = new URL(originalUrl);

    // 如果 dontCacheBustUrlsMatching 值没有设置，或是没有匹配到，将值拼接到url.serach后
    if (!dontCacheBustUrlsMatching ||
        !(url.pathname.match(dontCacheBustUrlsMatching))) {
        url.search += (url.search ? '&' : '') +
            encodeURIComponent(paramName) + '=' + encodeURIComponent(paramValue);
    }

    return url.toString();
};

var isPathWhitelisted = function (whitelist, absoluteUrlString) {
    // 如果 whitelist 是空数组，则认为全部都在白名单内
    if (whitelist.length === 0) {
        return true;
    }

    // 否则逐个匹配正则匹配并返回
    var path = (new URL(absoluteUrlString)).pathname;
    return whitelist.some(function (whitelistedPathRegex) {
        return path.match(whitelistedPathRegex);
    });
};

var stripIgnoredUrlParameters = function (originalUrl,
    ignoreUrlParametersMatching) {
    var url = new URL(originalUrl);
    // 移除 hash; 查看 https://github.com/GoogleChrome/sw-precache/issues/290
    url.hash = '';

    url.search = url.search.slice(1) // 是否包含 '?'
        .split('&') // 分割成数组 'key=value' 的形式
        .map(function (kv) {
            return kv.split('='); // 分割每个 'key=value' 字符串成 [key, value] 形式
        })
        .filter(function (kv) {
            return ignoreUrlParametersMatching.every(function (ignoredRegex) {
                return !ignoredRegex.test(kv[0]); // 如果 key 没有匹配到任何忽略参数正则，就 Return true
            });
        })
        .map(function (kv) {
            return kv.join('='); // 重新把 [key, value] 格式转换为 'key=value' 字符串
        })
        .join('&'); // 将所有参数 'key=value' 以 '&' 拼接

    return url.toString();
};


var addDirectoryIndex = function (originalUrl, index) {
    var url = new URL(originalUrl);
    if (url.pathname.slice(-1) === '/') {
        url.pathname += index;
    }
    return url.toString();
};

var hashParamName = '_sw-precache';
var urlsToCacheKeys = new Map(
    precacheConfig.map(function (item) {
        var relativeUrl = item[0];
        var hash = item[1];
        var absoluteUrl = new URL(relativeUrl, self.location);
        var cacheKey = createCacheKey(absoluteUrl, hashParamName, hash, false);
        return [absoluteUrl.toString(), cacheKey];
    })
);

function setOfCachedUrls(cache) {
    return cache.keys().then(function (requests) {
        // 如果原cacheName中没有缓存任何收，就默认是首次安装，否则认为是SW更新
        if (requests && requests.length > 0) {
            firstRegister = 0; // SW更新
        }
        return requests.map(function (request) {
            return request.url;
        });
    }).then(function (urls) {
        return new Set(urls);
    });
}

self.addEventListener('install', function (event) {
    event.waitUntil(
        caches.open(cacheName).then(function (cache) {
            return setOfCachedUrls(cache).then(function (cachedUrls) {
                return Promise.all(
                    Array.from(urlsToCacheKeys.values()).map(function (cacheKey) {
                        // 如果缓存中没有匹配到cacheKey，添加进去
                        if (!cachedUrls.has(cacheKey)) {
                            var request = new Request(cacheKey, { credentials: 'same-origin' });
                            return fetch(request).then(function (response) {
                                // 只要返回200才能继续，否则直接抛错
                                if (!response.ok) {
                                    throw new Error('Request for ' + cacheKey + ' returned a ' +
                                        'response with status ' + response.status);
                                }

                                return cleanResponse(response).then(function (responseToCache) {
                                    return cache.put(cacheKey, responseToCache);
                                });
                            });
                        }
                    })
                );
            });
        })
            .then(function () {
            
            // 强制 SW 状态 installing -> activate
            return self.skipWaiting();
            
        })
    );
});

self.addEventListener('activate', function (event) {
    var setOfExpectedUrls = new Set(urlsToCacheKeys.values());

    event.waitUntil(
        caches.open(cacheName).then(function (cache) {
            return cache.keys().then(function (existingRequests) {
                return Promise.all(
                    existingRequests.map(function (existingRequest) {
                        // 删除原缓存中相同键值内容
                        if (!setOfExpectedUrls.has(existingRequest.url)) {
                            return cache.delete(existingRequest);
                        }
                    })
                );
            });
        }).then(function () {
            
            return self.clients.claim();
            
        }).then(function () {
                // 如果是首次安装 SW 时, 不发送更新消息（是否是首次安装，通过指定cacheName 中是否有缓存信息判断）
                // 如果不是首次安装，则是内容有更新，需要通知页面重载更新
                if (!firstRegister) {
                    return self.clients.matchAll()
                        .then(function (clients) {
                            if (clients && clients.length) {
                                clients.forEach(function (client) {
                                    client.postMessage('sw.update');
                                })
                            }
                        })
                }
            })
    );
});



    self.addEventListener('fetch', function (event) {
        if (event.request.method === 'GET') {

            // 是否应该 event.respondWith()，需要我们逐步的判断
            // 而且也方便了后期做特殊的特殊
            var shouldRespond;


            // 首先去除已配置的忽略参数及hash
            // 查看缓存简直中是否包含该请求，包含就将shouldRespond 设为true
            var url = stripIgnoredUrlParameters(event.request.url, ignoreUrlParametersMatching);
            shouldRespond = urlsToCacheKeys.has(url);

            // 如果 shouldRespond 是 false, 我们在url后默认增加 'index.html'
            // (或者是你在配置文件中自行配置的 directoryIndex 参数值)，继续查找缓存列表
            var directoryIndex = 'index.html';
            if (!shouldRespond && directoryIndex) {
                url = addDirectoryIndex(url, directoryIndex);
                shouldRespond = urlsToCacheKeys.has(url);
            }

            // 如果 shouldRespond 仍是 false，检查是否是navigation
            // request， 如果是的话，判断是否能与 navigateFallbackWhitelist 正则列表匹配
            var navigateFallback = '';
            if (!shouldRespond &&
                navigateFallback &&
                (event.request.mode === 'navigate') &&
                isPathWhitelisted([], event.request.url)
            ) {
                url = new URL(navigateFallback, self.location).toString();
                shouldRespond = urlsToCacheKeys.has(url);
            }

            // 如果 shouldRespond 被置为 true
            // 则 event.respondWith()匹配缓存返回结果，匹配不成就直接请求.
            if (shouldRespond) {
                event.respondWith(
                    caches.open(cacheName).then(function (cache) {
                        return cache.match(urlsToCacheKeys.get(url)).then(function (response) {
                            if (response) {
                                return response;
                            }
                            throw Error('The cached response that was expected is missing.');
                        });
                    }).catch(function (e) {
                        // 如果捕获到异常错误，直接返回 fetch() 请求资源
                        console.warn('Couldn\'t serve response for "%s" from cache: %O', event.request.url, e);
                        return fetch(event.request);
                    })
                );
            }
        }
    });









/* eslint-enable */
